import { userInfoAPI } from '@/request/api';

export default {
    namespaced: true,
    state: {
        cartTotal: 0,
        userInfo: {
            nickName: '--',
            coin: '0',
            headImg: require('@/assets/img/userImg.f8bbec5e.png'),
        },
    },
    getters: {},
    mutations: {
        updateUserInfo(state, payload) {
            state.cartTotal = payload.cartTotal;
            state.userInfo = payload.userInfo;
            // console.log(payload);
        },
        inituserInfo(state, payload) {
            state.cartTotal = 0;
            state.userInfo = {
                nickName: '--',
                coin: '0',
                headImg: require('@/assets/img/userImg.f8bbec5e.png'),
            };
        },
    },
    actions: {
        async asyncuodateUserInfo(context) {
            // console.log(999);
            let res = await userInfoAPI();
            context.commit('updateUserInfo', res.data);
        },
    },
};
